from django.contrib.auth.models import AbstractUser
from django.db import models
from apps.config.models import Role_model,Dept_model
from apps.config.models import Jobs_model
# Create your models here.
# 这里使用自定义用户模型，并继承django框架自带的用户类
class Users_model(AbstractUser):
    user_code = models.CharField(max_length=16,  null=True, default=None,unique=True, verbose_name='用户代码')
    user_mobile = models.CharField(max_length=11, null=True,default=None, unique=True, verbose_name='用户手机号')
    user_avatar = models.ImageField(upload_to='avatars/',default='avatars/avatar.png', verbose_name='用户头像')
    user_id = models.CharField(max_length=18,  null=True,unique=True,verbose_name='身份证号')
    remark_describe = models.TextField(verbose_name='描述',  null=True)
    user_role = models.ManyToManyField(Role_model, verbose_name='所属角色')
    user_dept = models.ManyToManyField(Dept_model, verbose_name='所属部门')
    user_job = models.ManyToManyField(Jobs_model, verbose_name='岗位人员')
    is_sign = (
        (0, '拥有签字权'),
        (1, '没有签字权'),
    )
    sign_power = models.CharField(choices=is_sign, max_length=16,  null=False, default=1,
                                   verbose_name='是否拥有签字权')
    def __str__(self):
        return self.user_code

    class Meta:
        verbose_name_plural = '员工表'